﻿
using UnityEngine;
using UnityEngine.UI;
using TBFramework;
using System;

namespace UIController
{
    public class ToolsComponent : UIParentClass
    {
        public Button[] buttons;
        public Action<string, string, Sprite> action;
        public override void Init<T>(T values, Action<string, string, Sprite> _action)
        {
            action = _action;
            
            for (int i = 0; i < buttons.Length; i++)
            {
                string id = buttons[i].name;
                string name = buttons[i].transform.GetChild(1).GetComponent<Text>().text;
                Sprite sprite = buttons[i].transform.GetChild(0).GetComponent<Image>().sprite;
                buttons[i].onClick.AddListener(() =>
                {
                    action(id,name,sprite);
                });
            }
        }
    }
}
